﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace SomaiNordeste.FabricaRacao.DomainModel
{
    public static class InsumoExtensionMethods
    {
        public static string DateFormate(this Insumo _insumo)
        {
            //2010-11-20 13:38:43.140
            string ano = _insumo.Date.Year.ToString();
            string mes = _insumo.Date.Month > 9 ? _insumo.Date.Month.ToString() : "0" + _insumo.Date.Month.ToString();
            string dia = _insumo.Date.Day > 9 ? _insumo.Date.Day.ToString() : "0" + _insumo.Date.Day.ToString();
            string hora = DateTime.Now.Hour > 9 ? DateTime.Now.Hour.ToString() : "0" + DateTime.Now.Hour.ToString();
            string minutos = DateTime.Now.Minute > 9 ? DateTime.Now.Minute.ToString() : "0" + DateTime.Now.Minute.ToString();
            string segundos = DateTime.Now.Second > 9 ? DateTime.Now.Second.ToString() : "0" + DateTime.Now.Second.ToString();

            Thread.Sleep(500);

            string millisecond = DateTime.Now.Millisecond > 100 ? DateTime.Now.Millisecond.ToString() : "00" + DateTime.Now.Millisecond.ToString();
            //string hora = _insumo.Date.Hour > 9 ? _insumo.Date.Hour.ToString() : "0" + _insumo.Date.Hour.ToString();
            //string minutos = _insumo.Date.Minute > 9 ? _insumo.Date.Minute.ToString() : "0" + _insumo.Date.Minute.ToString();
            //string segundos = _insumo.Date.Second > 9 ? _insumo.Date.Second.ToString() : "0" + _insumo.Date.Second.ToString();


            return ano + "-" +
                mes + "-" +
                dia +
                " " +
                hora + ":" +
                minutos + ":" +
                segundos + ":" +
                millisecond;
        }
    }
}
